<?php

namespace App\Models\Feishu;

use App\Models\BaseModel;
use Illuminate\Support\Facades\Log;

class FsLoginLogModel extends BaseModel
{
    protected $table = "fs_login_logs";

    public $timestamps = false;

    protected $fillable = [
        'userId', 'feishuId', 'appId', 'platform', 'createdAt',
    ];

    public static function add(int $userId, string $feishuId, string $appId, string $platform)
    {
        try {
            return self::query()->create([
                'userId'    => $userId,
                'feishuId'  => $feishuId,
                'appId'     => $appId,
                'platform'  => $platform,
                'createdAt' => time(),
            ]);
        } catch (\Exception $e) {
            Log::warning($e);
            return null;
        }
    }
}
